#delimit ;
log using c:\expats\LINES\lines16\Tab1-3.log,replace;

use c:\expats\lines\lines16\pii-imp.dta;

* Amelia II used to impute missing data values, m=100, random number seed=902;
* See Supplemental Table 8 for question wordings;
* the key independent variables are loser2 (2=strong preference for unsuccessful candidate, 1=weak preference for an unsuccessful candidate, 0=did not prefer and unsuccessful candidate) and demidord2 (3=strong Democratic identifier, 2=weak Democratic ID, 1=lean Dem ID, 0=do not identify as a Democrat);
* original data are in _mi_m==0;

mi import flong, m(imp) id(ID_W1_W2_W3) imp(demidord2 loser2 
immrally3 rally1 partic1 partic3 
trustwash1 trustwash3 nosay1 nosay3 publicoffnocare1 publicoffnocare3
trustamer1 trustamer3 return1 return3
religpool timeus agepool schoolpool famincpool spanhome 
marriedpool ownhome 
female weight civicstatus freshw2 freshw3 mex
hometownassoc difstatelaw_2017);


** here is the replication .do file for Tables 1-3;

mi estimate: reg trustwash3 trustwash1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: reg nosay3 nosay1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: reg publicoffnocare3 publicoffnocare1   loser2 i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight];

mi estimate: reg trustamer3 trustamer1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: ologit return3 return1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;

mi estimate: logit immrally3 rally1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: ologit partic3 partic1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;


** predictor: thwarted partisan (3= strong Dem, 2=weak Dem, 1=lean Dem, 0=not Dem;

mi estimate: reg trustwash3 trustwash1 demidord2 i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: reg nosay3 nosay1 demidord2    i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;
mi estimate: reg publicoffnocare3 publicoffnocare1   demidord2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight];

mi estimate: reg trustamer3 trustamer1 demidord2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight];
mi estimate: ologit return3 return1 demidord2    i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] ;

mi estimate: logit immrally3 rally1 demidord2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight];
mi estimate: ologit partic3 partic1 demidord2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight];


** results for listwise deletion, for the supplemental files;

reg trustwash3 trustwash1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
reg nosay3 nosay1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
reg publicoffnocare3 publicoffnocare1   loser2 i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;

reg trustamer3 trustamer1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
ologit return3 return1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;

logit immrally3 rally1 loser2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
ologit partic3 partic1 loser2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;


** predictor: thwarted partisan (3= strong Dem, 2=weak Dem, 1=lean Dem, 0=not Dem;

reg trustwash3 trustwash1 demidord2 i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
reg nosay3 nosay1 demidord2    i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
reg publicoffnocare3 publicoffnocare1   demidord2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;

reg trustamer3 trustamer1 demidord2  i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
ologit return3 return1 demidord2    i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;

logit immrally3 rally1 demidord2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;
ologit partic3 partic1 demidord2   i.civicstatus time age span school faminc female ownhome relig mex difstatelaw_2017 [pweight=weight] if _mi_m == 0;

